﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq.Expressions;

namespace System.Web.Mvc.Html
{
    public static class HtmlExtensions
    {
        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes)
        {
            return htmlHelper.ValidationMessageFor<TModel, TProperty>(expression, null, htmlAttributes);
        }

        public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
        {
            return htmlHelper.ValidationMessageFor<TModel, TProperty>(expression, null, htmlAttributes);
        }

        public static String Html(this string str)
        {
            if (str == null)
                return null;
            str = str.Replace("\"", "&quot;");
            str = str.Replace("&", "&amp;");
            str = str.Replace("<", "&lt;");
            str = str.Replace(">", "&rt;");
            str = str.Replace("'", "&acute;");
            str = str.Replace("\n", " ");

            return str;
        }
    }
}